﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 护士工作站
{
    public partial class 护士工作站用户登录 : Form
    {
        public 护士工作站用户登录()
        {
            InitializeComponent();
        }

        private void button2_取消_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_确定_Click_1(object sender, EventArgs e)
        {
            if (tb_mc.Text.Trim() == "" || tb_mm.Text.Trim() == "")
            {
                MessageBox.Show("用户名或密码不能为空！");
                tb_mc.Focus();
                return;

            }
         string connString = DBHelper.connString;
           // string connString = @"Data Source=.\sqlexpress; Initial Catalog=hushigongzuozhan;Integrated Security=True";
            string sqlStr = string.Format("select * from Nurse where NurNo='{0}' and NurPassword='{1}'", tb_mc.Text.Trim(), tb_mm.Text.Trim());
            using (SqlConnection conn = new SqlConnection(connString))
            {
                SqlCommand cmd = new SqlCommand(sqlStr, conn);
                conn.Open();
                //int n = Convert.ToInt32(cmd.ExecuteScalar());
                SqlDataReader sdr = cmd.ExecuteReader();
                if (sdr.Read())
                {
                    //MessageBox.Show("登录成功！");
                    UserHelper.NurNo = tb_mc.Text.Trim();
                    UserHelper.NurPassword = tb_mm.Text.Trim();
                    this.Hide();
                    菜单页面 f = new 菜单页面();
                   f.WindowState = FormWindowState.Maximized;
                    f.Show();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误，请重新登录！", "错误");
                    tb_mc.Text = "";
                    tb_mm.Text = "";
                    tb_mc.Focus();
                }
                sdr.Close();
            }
            
        }
}
    }

